home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fatted Calf
/
The Fatted Calf.iso
/
Applications
/
Games
/
NeXTmille
/
Source
/
CardHolder.m
< prev
next >
Wrap
Text File
|
1990-12-01
|
3KB
|
224 lines
/* Generated by Interface Builder */
#import "CardHolder.h"
#import "angled_title.h"
#import "prototypes.h"
#import <libc.h>
#import <math.h>
#import <objc/objc.h>
#import <stdio.h>
#import <string.h>
@implementation CardHolder
+ newFrame:( const NXRect * )frameRect
{
self = [ super newFrame:frameRect ];
frameModeFlag = NO;
myTitle = calloc( 1, 1 );
return self;
}
- free
{
free( myTitle );
return [ super free ];
}
- sendCard:( CardView * )aCard to:anObject
{
fprintf( stderr, "Class=%s, received method=%s, superclass not responsible, subclasses should implement", [ self name ], sel_getName( _cmd ));
abort();
return self;
}
- sendAllCardsTo:anObject
{
fprintf( stderr, "Class=%s, received method=%s, superclass not responsible, subclasses should implement", [ self name ], sel_getName( _cmd ));
abort();
return self;
}
- addCard:( CardView * )aCard :sender
{
fprintf( stderr, "Class=%s, received method=%s, superclass not responsible, subclasses should implement", [ self name ], sel_getName( _cmd ));
abort();
return self;
}
- removeCard:( CardView * )aCard :sender
{
fprintf( stderr, "Class=%s, received method=%s, superclass not responsible, subclasses should implement", [ self name ], sel_getName( _cmd ));
abort();
return self;
}
- setCardsEnabled:( BOOL )flag
{
reactiveCardsFlag = flag;
return self;
}
- setTrackingEnabled:( BOOL )flag
{
trackingEnabledFlag = flag;
return self;
}
- ( BOOL )isTrackingEnabled
{
return trackingEnabledFlag;
}
- trackingHighlighted:( BOOL )flag
{
highlightModeFlag = flag;
return [[ self setNeedsDisplay:YES ] update ];
}
- setFrameMode:( BOOL )flag
{
frameModeFlag = flag;
[ window addToEventMask:NX_MOUSEENTEREDMASK+NX_MOUSEEXITEDMASK ];
return self;
}
- baseHolder
{
id searchView = self,
lastHolder = self;
while( searchView ) {
id theSuperview = [ searchView superview ];
if([ theSuperview isKindOf:[ CardHolder class ]])
lastHolder = theSuperview;
searchView = theSuperview;
}
return lastHolder;
}
- setTitle:( const char * )aTitle
{
free( myTitle );
strcpy(( myTitle = calloc(( strlen( aTitle ) + 8 ), sizeof( char ))), aTitle );
return self;
}
- ( BOOL )subviewVisible:aView
{
return YES;
}
- ( List * )holderList
{
return subviews;
}
- ( int )numCardTypeInHolder:( int )aCardTag
{
int i, cnt;
for( i = 0, cnt = 0; i < [ subviews count ]; ++i )
if([[ subviews objectAt:i ] tag ] == aCardTag )
++cnt;
return cnt;
}
- ( int )numSafetiesInHolder
{
int i, cnt;
for( i = 0, cnt = 0; i < [ subviews count ]; ++i )
if( isSafety([ subviews objectAt:i ]))
++cnt;
return cnt;
}
- drawSelf:( NXRect * )rects :( int )rectCount
{
float c_squared = hypot( NX_WIDTH( &bounds ), NX_HEIGHT( &bounds ));
float ourGray = [[ self opaqueAncestor ] backgroundGray ];
if( ourGray < 0.0 )
ourGray = [ window backgroundGray ];
PSsetgray( ourGray );
NXRectFill( &bounds );
if( highlightModeFlag ) {
PSsetgray( NX_WHITE );
NXFrameRectWithWidth( &bounds, 1 );
}
if( frameModeFlag ) {
NXRect frameBounds = bounds;
PSsetgray( NX_BLACK );
NXInsetRect( &frameBounds, 1.0, 1.0 );
NXFrameRectWithWidth( &frameBounds, 1 );
}
angled_title(( 180 / M_PI * asin( NX_HEIGHT( &bounds ) / c_squared )), c_squared, myTitle );
return self;
}
@end